package users

import (
	"gitee.com/xgotool/backend-framework-template/config"
	"gitee.com/xgotool/backend-framework-template/model"
)

// 获取用户的权限列表
//
//	uid	用户ID
func Pem(uid uint) ([]string, error) {
	menu_id, err := MenuId(uid)
	if err != nil {
		return nil, err
	}
	conn, err := config.GetConnect()
	if err != nil {
		return nil, err
	}
	pem := []string{}
	mod := model.Menu{}
	err = conn.Table(mod.TableName()).Where("id IN ?", menu_id).Pluck("permission", &pem).Error
	if err != nil {
		return nil, err
	}
	return pem, nil
}
